package com.aegis.autodeployplugin.service;

import com.aegis.autodeployplugin.entity.response.BaseResponse;
import com.aegis.autodeployplugin.entity.response.UploadResponse;
import com.aegis.autodeployplugin.entity.params.DingTalkRequestBody;

import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;

/**
 * desc     :
 *
 * @author : Aegis_Lee
 * date     : 2021/7/19
 * email    : 476810504@qq.com
 */
public interface ApiService {

    /**
     * 蒲公英上传App接口
     *
     *  {see https://www.pgyer.com/doc/view/api#uploadApp}
     *
     * @param apiKey apiKey
     * @param file  File
     * @param buildInstallType  值为(1,2,3，默认为1 公开安装)。1：公开安装，2：密码安装，3：邀请安装
     * @param buildPassword 设置App安装密码，密码为空时默认公开安装
     * @param buildUpdateDescription    更新内容
     * @param buildChannelShortcut  下载短链接，只可指定一个渠道，字符串型
     * @return UploadResponse
     */
    @Multipart
    @POST("apiv2/app/upload")
    Call<BaseResponse<UploadResponse>> upload(@Query("_api_key") String apiKey,
                                              @Part MultipartBody.Part file,
                                              @Query("buildInstallType") int buildInstallType,
                                              @Query("buildPassword") String buildPassword,
                                              @Query("buildUpdateDescription") String buildUpdateDescription,
                                              @Query("buildChannelShortcut") String buildChannelShortcut);

    /**
     * 钉钉机器人发送接口
     *
     * {see https://developers.dingtalk.com/document/app/custom-robot-access}
     *
     * @param accessToken  钉钉accessToken
     * @param timestamp 当前时间戳
     * @param sign  签名
     * @param body 消息体
     * @return  ResponseBody
     */
    @POST("robot/send")
    Call<ResponseBody> sendMessage(@Query("access_token") String accessToken,
                                   @Query("timestamp") Long timestamp,
                                   @Query("sign") String sign,
                                   @Body DingTalkRequestBody body);
}

